package project17;
    import java.util.Scanner;

    public class Test2 {

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int type = sc.nextInt();
            switch(type){
                case 1: test1(sc);break;
                case 2: test2(sc);break;
                case 3: test3(sc);break;
                case 4: test4(sc);
            }
        }
        //test方法为（4）中情况，见上述说明
        public static void test1(Scanner sc) {
          for(int i=0;i<2;++i)
          {
              String id=sc.next();
              String name=sc.next();
              Student a=new Student();
              a.setStuName(name);
              a.setStuID(id);
          }
            System.out.println("学生总数为："+Student.getStuNum());
        }
        public static void test2(Scanner sc) {
            for(int i=0;i<3;++i)
            {
                String id=sc.next();
                String name=sc.next();
                Course b=new Course();
                b.setcName(name);
                b.setcID(id);
            }
            System.out.println("课程总数为："+Course.getcNum());

        }

        public static void test3(Scanner sc) {
            String id=sc.next();
            String name=sc.next();
            Student s1=new Student(id,name);
            Course c1=new Course();
            Course c2=new Course();
            c1.setcID(sc.next());
            c1.setcName(sc.next());
            c2.setcID(sc.next());
            c2.setcName(sc.next());
            Schedule sch=new Schedule();
            sch.addCourse(s1,c1);
            sch.addCourse(s1,c2);
            System.out.println("学生选课的总数为："+Schedule.getSchNum());
            System.out.println("学生选课情况如下：");
            sch.displayCourse();
        }
        public static void test4(Scanner sc) {
            String id=sc.next();
            String name=sc.next();
            Student s1=new Student(id,name);
            Student s2=new Student(sc.next(),sc.next());
            Student s3=new Student(sc.next(),sc.next());
            Course c1=new Course(sc.next(), sc.next());
            Course c2=new Course(sc.next(), sc.next());
            Course c3=new Course(sc.next(), sc.next());
            Course c4=new Course(sc.next(), sc.next());
            Schedule sch=new Schedule();
            sch.addCourse(s1,c2);
            sch.addCourse(s1,c3);
            sch.addCourse(s2,c1);
            sch.addCourse(s3,c1);
            sch.addCourse(s3,c2);
            sch.addCourse(s3,c4);
            System.out.println("学生总数为："+Student.getStuNum());
            System.out.println("课程总数为："+Course.getcNum());
            System.out.println("学生选课的总数为："+Schedule.getSchNum());
            System.out.println("学生选课情况如下：");
            sch.displayCourse();
        }
    }

    // 学生类Student
    class Student{
        private String stuID;
        private String stuName;
        private static int stuNum=0;
        private  Course[] stuCourse=new Course[10];

        public Student() {
            System.out.println("学生类无参构造方法");
            stuNum++;
        }

        public Student(String stuID, String stuName) {
            this.stuID = stuID;
            this.stuName = stuName;
            stuNum++;
            System.out.println("学生类有参构造方法");
        }

        public String getStuID() {
            return stuID;
        }

        public String getStuName() {
            return stuName;
        }

        public static int getStuNum() {
            return stuNum;
        }

        public Course[] getStuCourse() {
            return stuCourse;
        }

        public void setStuID(String stuID) {
            this.stuID = stuID;
        }

        public void setStuName(String stuName) {
            this.stuName = stuName;
        }
        public void setStuCourse(Course n)
        {
            int i=0;
            for(i=0;stuCourse[i]!=null;++i);
            stuCourse[i]=n;
        }

    }

    // 课程类Course
    class Course{
        private String cID;
        private String cName;
        private static int cNum=0;

        public Course() {
            System.out.println("课程类无参构造方法");
            cNum++;
        }

        public Course(String cID, String cName) {
            this.cID = cID;
            this.cName = cName;
            System.out.println("课程类有参构造方法");
            cNum++;
        }

        public String getcID() {
            return cID;
        }

        public String getcName() {
            return cName;
        }

        public static int getcNum() {
            return cNum;
        }

        public void setcName(String cName) {
            this.cName = cName;
        }

        public void setcID(String cID) {
            this.cID = cID;
        }
    }

    // 学生选课类Schedule
    class Schedule{
        private Student[] stuList;
        private Course[] cList;
        private static int schNum;
        static int flag=0;
        public Schedule() {
            stuList=new Student[10];
            cList=new Course[10];
        }

        public static int getSchNum() {
            return schNum;
        }

        public void addCourse(Student stu, Course course)
        {
            schNum++;
            int i,j=0,k;
            for(i=0;stuList[i]!=null;++i)
            {
                if(stuList[i]==stu)
                {
                    j=1;
                    break;
                }
            }
            if(j==0)
            {
                stuList[i]=stu;
            }
            stu.setStuCourse(course);
        }

        public void displayCourse()
        {
            int i=0,j=0,k;

            for(i=0;stuList[i]!=null;++i) {
                Course[] stuCourse=stuList[i].getStuCourse();
                for(j=0;stuCourse[j]!=null;++j)
                {
                    System.out.println(stuList[i].getStuID()+"\t"+stuList[i].getStuName()+"\t"+stuCourse[j].getcID()+"\t"+stuCourse[j].getcName());
                }
            }
        }
    }